package com.antis.olsl.magic.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.antis.olsl.magic.R;
import com.antis.olsl.magic.adapter.StaveDialogAdapter;

import java.util.List;

/**
 * 五线谱弹出提示框
 *
 * @author hhh
 */
public class StaveDialog {
    private Context mContext;
    private List<String> mList;
    private AlertDialog mDialog;

    private StaveDialog() {
    }

    public StaveDialog(Context context, List<String> list) {
        this.mContext = context;
        this.mList = list;
    }

    public void show() {
        mDialog = new AlertDialog.Builder(mContext, R.style.UploadImgDiaLog).create();
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_stave, null);
        mDialog.show();
        mDialog.setContentView(view);

        RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
        StaveDialogAdapter adapter = new StaveDialogAdapter(R.layout.item_stave_dialog, mList);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(adapter);
        Button btnOk = view.findViewById(R.id.btn_ok);
        btnOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public void dismiss() {
        if (null != mDialog) {
            mDialog.dismiss();
        }
    }
}
